<template>
  <div class="search">
    <div class="searchinput">
      <span @click="$router.go(-1)">返回</span>
      <input type="text" placeholder="搜索商品" v-model="searchText" />
      <span @click="search">搜索</span>
    </div>
    <div class="block">
      <h3>历史搜索</h3>
      <div class="list">
        <span v-for="(item, index) in searchArr" :key="index">{{ item }}</span>
      </div>
    </div>
    <div class="sea">
      <h3>搜索发现</h3>
      <div>
        <span>麻辣烫</span>
        <span>汉堡包</span>
        <span>米线</span>
        <span>披萨</span>
        <span>蛋糕</span>
        <span>味多美(科技路店)</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchText: "",
      searchArr: ["三文鱼", "鲍鱼", "炒饭"],
    };
  },
  methods: {
    search() {
      this.searchArr.unshift(this.searchText);
      this.searchText = "";
    },
  },
};
</script>

<style lang='scss' scoped>
* {
  margin: 0;
  padding: 0;
}

.searchinput {
  text-align: center;
  margin-top: 10px;
  display: flex;
  justify-content: space-around;
  align-content: center;
}

.searchinput input {
  width: 70%;
  height: 30px;
  background-color: #f5f5f5;
  border: none;
  border-radius: 20px;
  outline: none;
}

.searchinput span {
  line-height: 30px;
  color: rgb(15, 173, 236);
}

.block {
  margin-top: 20px;
}

.block .list span {
  margin-top: 10px;
  margin-left: 10px;
  padding: 5px 10px;
  background-color: #f5f5f5;
  display: inline-block;
  border-radius: 10px;
}
.sea > h3 {
  margin-top: 20px;
}
.sea > div > span {
  margin-top: 10px;
  margin-left: 10px;
  padding: 5px 10px;
  background-color: #f5f5f5;
  display: inline-block;
  border-radius: 10px;
}
</style>